using Microsoft.AspNetCore.Mvc;
using Lzfy_His_Service.Services;
using Oracle.ManagedDataAccess.Client;
using System.Net.NetworkInformation;
using System.Net.Sockets;

namespace Lzfy_His_Service.Controllers
{
    /// <summary>
    /// 诊断控制器 - 用于系统诊断和故障排查
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    [ApiExplorerSettings(IgnoreApi = true)]
    public class DiagnosticsController : ControllerBase
    {
        private readonly IDatabaseConfigurationService _dbConfig;
        private readonly IOracleConnectionFactory _oracleConnectionFactory;
        private readonly ILogger<DiagnosticsController> _logger;

        public DiagnosticsController(
            IDatabaseConfigurationService dbConfig,
            IOracleConnectionFactory oracleConnectionFactory,
            ILogger<DiagnosticsController> logger)
        {
            _dbConfig = dbConfig;
            _oracleConnectionFactory = oracleConnectionFactory;
            _logger = logger;
        }

        /// <summary>
        /// 测试Oracle数据库连接 - 已禁用
        /// </summary>
        /// <returns>禁用状态</returns>
        [HttpPost("test-oracle-connection")]
        public IActionResult TestOracleConnection()
        {
            _logger.LogWarning("诊断接口已被禁用");
            return NotFound(new { message = "此接口已被禁用" });
        }

        /// <summary>
        /// 测试网络连通性 - 已禁用
        /// </summary>
        /// <param name="request">网络测试请求</param>
        /// <returns>禁用状态</returns>
        [HttpPost("test-network")]
        public IActionResult TestNetwork([FromBody] NetworkTestRequest request)
        {
            _logger.LogWarning("网络测试接口已被禁用");
            return NotFound(new { message = "此接口已被禁用" });
        }

        /// <summary>
        /// 获取当前数据库配置信息 - 已禁用
        /// </summary>
        /// <returns>禁用状态</returns>
        [HttpGet("database-config")]
        public IActionResult GetDatabaseConfig()
        {
            _logger.LogWarning("数据库配置接口已被禁用");
            return NotFound(new { message = "此接口已被禁用" });
        }

        /// <summary>
        /// 系统健康检查 - 已禁用
        /// </summary>
        /// <returns>禁用状态</returns>
        [HttpGet("health-check")]
        public IActionResult HealthCheck()
        {
            _logger.LogWarning("健康检查接口已被禁用");
            return NotFound(new { message = "此接口已被禁用" });
        }
    }

    public class NetworkTestRequest
    {
        public string Host { get; set; } = string.Empty;
        public int Port { get; set; }
    }
}